﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using GreyGate.Utils;
using GreyGate.Screens;

namespace GreyGate.Objects
{
    class Room
    {
        private DrawModel drawModel;

        private Model room;
        private Matrix[] boneTransforms;

        private int roomKind;

        private Vector2 position;

        private bool moveFront = false, 
                       frontIsMust = false,
                     moveRight = false,
                       rightIsMust = false,
                     moveBack  = false,
                       backIsMust = false,
                     moveLeft  = false,
                      leftIsMust = false;

        private bool entrance, exit;

        Random rnd;

        public Room(ref Room[,] labyrinth, ContentManager content, Vector2 position)
        {
            drawModel = new DrawModel();
            this.position = position;
            this.entrance = false;
            this.exit = false;

            // Voreinstellungen für getConstraints()
                     moveFront = true; 
                     moveRight = true;
                     moveBack = true;
                     moveLeft = true;

                     rnd = new Random();
            getConstraints(ref labyrinth);
            setRoomWithConstraints(content);
            setSurroundingRooms(ref labyrinth);
        }

        public Room(ContentManager content, ref Room[,] labyrinth, Vector2 position, bool entrance, bool exit)
        {
            this.position = position;
            this.entrance = entrance;
            this.exit = exit;
            
            rnd = new Random();

            getConstraints(ref labyrinth);

            setMaxRoomWithConstraints(content);

            if(entrance){
                moveFront = false;
            }
            if (exit)
            {
                moveBack = false;
            }

            setSurroundingRooms(ref labyrinth);
        }

        public Room(int RoomKind, ContentManager content)
        {
            drawModel = new DrawModel();
            //this.specialRoom = specialRoom;

            setConstraints(RoomKind);

            switch (RoomKind)
            {
                case 0:
                    room = content.Load<Model>("Models\\0");
                    break;
                case 1:
                    room = content.Load<Model>("Models\\1");
                    break;
                case 2:
                    room = content.Load<Model>("Models\\2");
                    break;
                case 3:
                    room = content.Load<Model>("Models\\3");
                    break;
                case 4:
                    room = content.Load<Model>("Models\\4");
                    break;
                case 5:
                    room = content.Load<Model>("Models\\5");
                    break;
                case 6:
                    room = content.Load<Model>("Models\\6");
                    break;
                case 7:
                    room = content.Load<Model>("Models\\7");
                    break;
                case 8:
                    room = content.Load<Model>("Models\\8");
                    break;
                case 9:
                    room = content.Load<Model>("Models\\9");
                    break;
                case 10:
                    room = content.Load<Model>("Models\\10");
                    break;
                case 11:
                    room = content.Load<Model>("Models\\11");
                    break;
                case 12:
                    room = content.Load<Model>("Models\\12");
                    break;
                case 13:
                    room = content.Load<Model>("Models\\13");
                    break;
                case 14:
                    room = content.Load<Model>("Models\\14");
                    break;
                case -1:
                    room = null;
                    break;
            }// end switch
            if (room != null)
            {
                boneTransforms = new Matrix[room.Bones.Count];
            }
            else
            {
                boneTransforms = null;
            }
            
        }

        public void drawRoom(Vector3 position, Vector3 cameraPosition, Matrix lookAt, float lookAngle)
        {
            drawModel.Draw( room, boneTransforms,
                            lookAt,
                            UtilityVariables.fieldOfView,
                            position,
                            UtilityVariables.scale,
                            lookAngle );
        }

        private void setConstraints(int RoomKind)
        {
            switch (RoomKind)
            {
                case 0:// korrekt
                    moveFront = true;
                    moveBack = true;
                    moveLeft = false;
                    moveRight = false;
                    roomKind = 0;
                    break;
                case 1: // korrekt
                    moveFront = false;
                    moveBack = false;
                    moveLeft = true;
                    moveRight = true;
                    roomKind = 1;
                    break;
                case 2: // korrekt
                    moveFront = false;
                    moveBack = true;                    
                    moveLeft = true;
                    moveRight = false;  
                    roomKind = 2;
                    break; 
                case 3: // korrekt
                    moveFront = true;
                    moveBack = false;
                    moveLeft = true;                    
                    moveRight = false;                    
                    roomKind = 3;
                    break;
                case 4: // korrekt
                    moveFront = true;
                    moveBack = false;
                    moveLeft = false;
                    moveRight = true;
                    roomKind = 4;
                    break;
                case 5: // korrekt
                    moveFront = false;
                    moveBack = true;
                    moveLeft = false;
                    moveRight = true;
                    roomKind = 5;
                    break;
                case 6: // korrekt
                    moveFront = false;
                    moveBack = true;
                    moveLeft = true;                    
                    moveRight = true;                    
                    roomKind = 6;
                    break;
                case 7: // korrekt
                    moveFront = true;
                    moveBack = true;
                    moveLeft = true;
                    moveRight = false;
                    roomKind = 7;
                    break;
                case 8: // korrekt
                    moveFront = true;
                    moveBack = false;
                    moveLeft = true;
                    moveRight = true;                    
                    roomKind = 8;
                    break;
                case 9: // korrekt
                    moveFront = true;
                    moveBack = true;
                    moveLeft = false;
                    moveRight = true;                    
                    roomKind = 9;
                    break;
                case 10: // korrekt
                    moveFront = true;
                    moveBack = true;
                    moveLeft = true;
                    moveRight = true;                    
                    roomKind = 10;
                    break;
                case 11: // korrekt
                    moveFront = false;
                    moveBack = true;
                    moveLeft = false;
                    moveRight = false;                    
                    roomKind = 11;
                    break;
                case 12: // korrekt
                    moveFront = false;
                    moveBack = false;
                    moveLeft = true;
                    moveRight = false;                    
                    roomKind = 12;
                    break;
                case 13: // korrekt
                    moveFront = true;
                    moveBack = false;
                    moveLeft = false;
                    moveRight = false;
                    roomKind = 13;
                    break;
                case 14: // korrekt
                    moveFront = false;
                    moveBack = false;
                    moveLeft = false;
                    moveRight = true;
                    roomKind = 14;
                    break;
            }
        }

        public void getConstraints(ref Room[,] labyrinth)
        {
            Room front, right, back, left;

            bool leftborder = false,
                 frontborder = false,
                 rightborder = false,
                 backborder = false;
            // Hier werden die Constraints so gesetzt, dass kein Weg aus dem Labyrinth
            // hinausführen kann.
            #region Ist dieser Raum ein Randraum?
            if (position.Y - 1 >= 0)
            {
                front = labyrinth[(int)position.Y - 1, (int)position.X];
            }
            else
            {
                front = null;
                moveFront = false;
                frontborder = true;
            }

            if (position.X + 1 < UtilityVariables.labyrinthSize)
            {
                right = labyrinth[(int)position.Y, (int)position.X + 1];
            }
            else
            {
                right = null;
                moveRight = false;
                rightborder = true;
            }

            if (position.Y + 1 < UtilityVariables.labyrinthSize)
            {
                back = labyrinth[(int)position.Y + 1, (int)position.X];
            }
            else
            {
                back = null;
                moveBack = false;
                backborder = true;
            }

            if (position.X - 1 >= 0)
            {
                left = labyrinth[(int)position.Y, (int)position.X - 1];
            }
            else
            {
                left = null;
                moveLeft = false;
                leftborder = true;
            }
            #endregion

            /*
             * Hier muss nun noch überlegt werden was passieren soll, wenn man auf einen
             * Raum zugreift, der direkt vor einem liegt, der aber noch nicht definiert
             * und damit noch null ist. 
             * Um dies zu berücksichtigen, nimmt das Programm erstmal an, dass es Wege
             * in jede Richtung legen darf. Dadurch kann man den Fall, dass vor einem
             * noch nichts ist, ignoriert werden, da bereits angenommen wird, dass man
             * dort hin darf. Dann wird überprüft, ob es sich hier um
             * einen Randraum handelt und wenn ja , wird der entsprechende Weg wieder
             * still gelegt, damit keine offenen Wege ins Nichts entstehen.
             */
            // Hier wird diesem Raum gesagt, ob es Anschlussverbindungen an die
            // umliegenden Räume geben muss, oder nicht darf.
            #region Setze die Wege für die Anschlussräume
            //---------------------------------------------------
            if (front != null)
            {
                if (!front.MovesBack)
                {
                    moveFront = false;
                }
                else
                {
                    moveFront = true;
                    frontIsMust = true;
                    front.BackIsMust = true;
                }
            }
            else if (!frontborder)
            {
                moveFront = true;
            }
            //---------------------------------------------------
            
            if (left != null)
            {
                if (!left.moveRight)
                {
                    moveLeft = false;
                }
                else
                {
                    moveLeft = true;
                    leftIsMust = true;
                    left.RightIsMust = true;
                }
            }
            else if (!leftborder)
            {
                moveLeft = true;
            }
            // ----------------------------------------
            if (right != null)
            {
                if (!right.moveLeft)
                {
                    moveRight = false;
                }
                else
                {
                    moveRight = true;
                    rightIsMust = true;
                    right.LeftIsMust = true;
                }
            }
            else if (!rightborder)
            {
                moveRight = true;
            }
            //--------------------------------------------
            if (back != null)
            {
                if (!back.moveFront)
                {
                    moveBack = false;
                }
                else
                {
                    moveBack = true;
                    backIsMust = true;
                    back.FrontIsMust = true;
                }
            }
            else if (!backborder)
            {
                moveBack = true;
            }
            //------------------------------------------------
            #endregion
        }

        public void setRoomWithConstraints(ContentManager content)
        {
            #region Wenn es Sackgassen sein müssen
            // Wenn es nur einen Weg nach Rechts geben darf
            if(!MovesFront && !MovesBack && !MovesLeft && MovesRight)           
            {
                room = content.Load<Model>("Models\\14");
                setConstraints(14);
            }
            // Wenn es nur einen Weg nach links geben darf
            if (!MovesFront && !MovesBack && !MovesRight && MovesLeft)
            {
                room = content.Load<Model>("Models\\12");
                setConstraints(12);
            }
            // Wenn es nur einen Weg nach vorne geben darf
            if (!MovesLeft && !MovesBack && !MovesRight && MovesFront)
            {
                room = content.Load<Model>("Models\\13");
                setConstraints(13);
            }
            // Wenn es nur einen Weg nach hinten geben darf
            if (!MovesLeft && !MovesFront && !MovesRight && MovesBack)
            {
                room = content.Load<Model>("Models\\11");
                setConstraints(11);
            }
            #endregion

            #region Wenn es maximal zwei Wege sein können

            // Mehrfach überprüft. Ist jetzt korrekt.
            #region die Möglichkeiten von links und unten
            if (!MovesFront && !MovesRight && MovesBack && MovesLeft){
                // Wenn der Weg von links nach unten sein muss
                if (backIsMust && leftIsMust)
                {
                    room = content.Load<Model>("Models\\2"); // von links nach unten
                    setConstraints(2);
                }
                else
                {
                    if (backIsMust && !leftIsMust)
                    {    
                        int newRoom = rnd.Next(2);
                        switch(newRoom){
                            case 0: // Sackgasse Weg nach unten
                                room = content.Load<Model>("Models\\11");
                                setConstraints(11);
                                break;
                            case 1:// Weg - links-unten
                                room = content.Load<Model>("Models\\2");
                                setConstraints(2);
                                break;
                        }
                    }
                    else if (!backIsMust && leftIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach links
                                room = content.Load<Model>("Models\\12");
                                setConstraints(12);
                                break;
                            case 1:// Weg - links-unten
                                room = content.Load<Model>("Models\\2");
                                setConstraints(2);
                                break;
                        }
                    }
                    else
                    {
                        int newRoom = rnd.Next(3);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach unten
                                room = content.Load<Model>("Models\\11");
                                setConstraints(11);
                                break;
                            case 1: // Weg - links-unten
                                room = content.Load<Model>("Models\\2");
                                setConstraints(2);
                                break;
                            case 2: // Weg links
                                room = content.Load<Model>("Models\\12");
                                setConstraints(12);
                                break;
                        }
                    }                    
                }
            }
            #endregion

            // Sollte nun ebenfalls korrekt sein.
            #region Die Möglichkeiten von links und oben
            if (MovesFront && !MovesRight && !MovesBack && MovesLeft)
            {
                // Wenn der Weg von links nach oben sein muss
                if (frontIsMust && leftIsMust)
                {
                    room = content.Load<Model>("Models\\3"); // von links nach oben
                    setConstraints(3);
                }
                else
                {
                    if (frontIsMust && !leftIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach oben
                                room = content.Load<Model>("Models\\13");
                                setConstraints(13);
                                break;
                            case 1:// Weg - links-oben
                                room = content.Load<Model>("Models\\3");
                                setConstraints(3);
                                break;
                        }
                    }
                    else if (!frontIsMust && leftIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach links
                                room = content.Load<Model>("Models\\12");
                                setConstraints(12);
                                break;
                            case 1:// Weg - links-oben
                                room = content.Load<Model>("Models\\3");
                                setConstraints(3);
                                break;
                        }
                    }
                    else
                    {
                        int newRoom = rnd.Next(3);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach oben
                                room = content.Load<Model>("Models\\13");
                                setConstraints(13);
                                break;
                            case 1: // Weg - links-oben
                                room = content.Load<Model>("Models\\3");
                                setConstraints(3);
                                break;
                            case 2: // Weg links
                                room = content.Load<Model>("Models\\12");
                                setConstraints(12);
                                break;
                        }
                    }
                }
            }
            #endregion

            // Scheint auch zu stimmen
            #region Die Möglichkeiten von links und rechts
            if (!MovesFront && MovesRight && !MovesBack && MovesLeft)
            {
                // Wenn der Weg von links nach rechts sein muss
                if (rightIsMust && leftIsMust)
                {
                    room = content.Load<Model>("Models\\1"); // von links nach oben
                    setConstraints(1);
                }
                else
                {
                    if (rightIsMust && !leftIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach oben
                                room = content.Load<Model>("Models\\14");
                                setConstraints(14);
                                break;
                            case 1:// Weg - links-oben
                                room = content.Load<Model>("Models\\1");
                                setConstraints(1);
                                break;
                        }
                    }
                    else if (!rightIsMust && leftIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach links
                                room = content.Load<Model>("Models\\12");
                                setConstraints(12);
                                break;
                            case 1:// Weg - links-oben
                                room = content.Load<Model>("Models\\1");
                                setConstraints(1);
                                break;
                        }
                    }
                    else
                    {
                        int newRoom = rnd.Next(3);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach links
                                room = content.Load<Model>("Models\\12");
                                setConstraints(12);
                                break;
                            case 1: // Weg - links-oben
                                room = content.Load<Model>("Models\\1");
                                setConstraints(1);
                                break;
                            case 2: // Weg rechts
                                room = content.Load<Model>("Models\\14");
                                setConstraints(14);
                                break;
                        }
                    }
                }
            }
            #endregion

            // Stimmt hoffentlich
            #region Die Möglichkeiten von oben und rechts
            if (MovesFront && MovesRight && !MovesBack && !MovesLeft)
            {
                // Wenn der Weg von vorne nach rechts sein muss
                if (rightIsMust && frontIsMust)
                {
                    room = content.Load<Model>("Models\\4"); // von links nach oben
                    setConstraints(4);
                }
                else
                {
                    if (rightIsMust && !frontIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg von rechts
                                room = content.Load<Model>("Models\\14");
                                setConstraints(14);
                                break;
                            case 1:// Weg - oben-rechts
                                room = content.Load<Model>("Models\\4");
                                setConstraints(4);
                                break;
                        }
                    }
                    else if (!rightIsMust && frontIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach vorne
                                room = content.Load<Model>("Models\\13");
                                setConstraints(13);
                                break;
                            case 1:// Weg - oben-rechts
                                room = content.Load<Model>("Models\\4");
                                setConstraints(4);
                                break;
                        }
                    }
                    else
                    {
                        int newRoom = rnd.Next(3);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg von oben
                                room = content.Load<Model>("Models\\13");
                                setConstraints(13);
                                break;
                            case 1: // Weg - rechts-oben
                                room = content.Load<Model>("Models\\4");
                                setConstraints(4);
                                break;
                            case 2: // Weg rechts
                                room = content.Load<Model>("Models\\14");
                                setConstraints(14);
                                break;
                        }
                    }
                }
            }
            #endregion

            // Sollte stimmen
            #region Die Möglichkeiten von unten und rechts
            if (!MovesFront && MovesRight && MovesBack && !MovesLeft)
            {
                // Wenn der Weg von vorne nach rechts sein muss
                if (rightIsMust && backIsMust)
                {
                    room = content.Load<Model>("Models\\5"); // von links nach oben
                    setConstraints(5);
                }
                else
                {
                    if (rightIsMust && !backIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg von rechts
                                room = content.Load<Model>("Models\\14");
                                setConstraints(14);
                                break;
                            case 1:// Weg - oben-rechts
                                room = content.Load<Model>("Models\\5");
                                setConstraints(5);
                                break;
                        }
                    }
                    else if (!rightIsMust && backIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach vorne
                                room = content.Load<Model>("Models\\11");
                                setConstraints(11);
                                break;
                            case 1:// Weg - oben-rechts
                                room = content.Load<Model>("Models\\5");
                                setConstraints(5);
                                break;
                        }
                    }
                    else
                    {
                        int newRoom = rnd.Next(3);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg von oben
                                room = content.Load<Model>("Models\\11");
                                setConstraints(11);
                                break;
                            case 1: // Weg - rechts-oben
                                room = content.Load<Model>("Models\\5");
                                setConstraints(5);
                                break;
                            case 2: // Weg rechts
                                room = content.Load<Model>("Models\\14");
                                setConstraints(14);
                                break;
                        }
                    }
                }
            }
            #endregion

            // Sollte goffentlich stimmen
            #region Die Möglichkeiten von oben und unten
            if (MovesFront && !MovesRight && MovesBack && !MovesLeft)
            {
                // Wenn der Weg von vorne nach rechts sein muss
                if (frontIsMust && backIsMust)
                {
                    room = content.Load<Model>("Models\\0"); // von links nach oben
                    setConstraints(0);
                }
                else
                {
                    if (frontIsMust && !backIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg von oben
                                room = content.Load<Model>("Models\\13");
                                setConstraints(13);
                                break;
                            case 1:// Weg - oben-unten
                                room = content.Load<Model>("Models\\0");
                                setConstraints(0);
                                break;
                        }
                    }
                    else if (!frontIsMust && backIsMust)
                    {
                        int newRoom = rnd.Next(2);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach unten
                                room = content.Load<Model>("Models\\11");
                                setConstraints(11);
                                break;
                            case 1:// Weg - oben-unten
                                room = content.Load<Model>("Models\\0");
                                setConstraints(0);
                                break;
                        }
                    }
                    else
                    {
                        int newRoom = rnd.Next(3);
                        switch (newRoom)
                        {
                            case 0: // Sackgasse Weg nach unten
                                room = content.Load<Model>("Models\\11");
                                setConstraints(11);
                                break;
                            case 1: // Weg - oben-unten
                                room = content.Load<Model>("Models\\0");
                                setConstraints(0);
                                break;
                            case 2: // Weg oben
                                room = content.Load<Model>("Models\\13");
                                setConstraints(13);
                                break;
                        }
                    }
                }
            }
            #endregion
            #endregion

            #region Wenn es maximal 3 Wege sein können

            #region Wenn der Weg nach links nicht offen sein darf
            if (MovesFront && MovesRight && MovesBack && !MovesLeft)
            {
                if (frontIsMust && rightIsMust && backIsMust) // 9
                {
                    room = content.Load<Model>("Models\\9"); // links geschlossen
                    setConstraints(9);
                }
                else if (frontIsMust && rightIsMust && !backIsMust) // 4, 9
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\4"); // links-unten geschlossen
                            setConstraints(4);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && backIsMust) // 0, 9
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\0"); // links-unten geschlossen
                            setConstraints(0);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && backIsMust) // 5, 9
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\5"); // links-unten geschlossen
                            setConstraints(5);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && !backIsMust) // 0, 4, 9, 13
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\0"); // links-unten geschlossen
                            setConstraints(0);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\4"); // links-unten geschlossen
                            setConstraints(4);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\13"); // links-unten geschlossen
                            setConstraints(13);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && !backIsMust) // 4, 5, 9, 14
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\4"); // links-unten geschlossen
                            setConstraints(4);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\5"); // links-unten geschlossen
                            setConstraints(5);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\14"); // links-unten geschlossen
                            setConstraints(14);
                            break;
                    }
                }
                else if (!frontIsMust && !rightIsMust && backIsMust) // 0, 5, 9, 11
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\0"); // links-unten geschlossen
                            setConstraints(0);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\5"); // links-unten geschlossen
                            setConstraints(5);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\11"); // links-unten geschlossen
                            setConstraints(11);
                            break;
                    }
                }
                else // 0, 4, 5, 9, 11, 13, 14
                {
                    int newRoom = rnd.Next(7);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9"); // links geschlossen
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\0"); // links-unten geschlossen
                            setConstraints(0);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\4"); // links-unten geschlossen
                            setConstraints(4);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\5"); // links-unten geschlossen
                            setConstraints(5);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\11"); // links-unten geschlossen
                            setConstraints(11);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\13"); // links-unten geschlossen
                            setConstraints(13);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\14"); // links-unten geschlossen
                            setConstraints(14);
                            break;
                    }
                }
            }
            #endregion

            #region Wenn der Weg nach hinten nicht offen sein darf
            if (MovesFront && MovesRight && !MovesBack && MovesLeft)
            {
                if (frontIsMust && rightIsMust && leftIsMust) // 8
                {
                    room = content.Load<Model>("Models\\8"); //
                    setConstraints(8);
                }
                else if (frontIsMust && rightIsMust && !leftIsMust) // 4, 8
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\4"); //
                            setConstraints(4);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\8"); //
                            setConstraints(8);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && leftIsMust) // 3, 8
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\3"); //
                            setConstraints(3);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\8"); //
                            setConstraints(8);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && leftIsMust) // 1, 8
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); // 
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\8"); // 
                            setConstraints(8);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && !leftIsMust) // 3, 4, 8, 13
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\3"); //
                            setConstraints(3);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\4"); //
                            setConstraints(4);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\8"); //
                            setConstraints(8);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\13"); //
                            setConstraints(13);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && !leftIsMust) // 1, 4, 8, 14
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); //
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\4"); //
                            setConstraints(4);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\8"); //
                            setConstraints(8);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\14"); //
                            setConstraints(14);
                            break;
                    }
                }
                else if (!frontIsMust && !rightIsMust && leftIsMust) // 1, 3, 8, 12
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); //
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\3"); //
                            setConstraints(3);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\8"); //
                            setConstraints(8);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\12"); //
                            setConstraints(12);
                            break;
                    }
                }
                else // 1, 3, 4, 8, 12, 13, 14
                {
                    int newRoom = rnd.Next(7);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); //
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\3"); //
                            setConstraints(3);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\4"); // 
                            setConstraints(4);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\8"); //
                            setConstraints(8);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\12"); //
                            setConstraints(12);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\13"); // 
                            setConstraints(13);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\14"); //
                            setConstraints(14);
                            break;
                    }
                }
            }
            #endregion

            #region Wenn der Weg nach rechts nicht offen sein darf
            if (MovesFront && !MovesRight && MovesBack && MovesLeft)
            {
                if (frontIsMust && backIsMust && leftIsMust) // 7
                {
                    room = content.Load<Model>("Models\\7"); // rechts geschlossen
                    setConstraints(7);
                }
                else if (frontIsMust && backIsMust && !leftIsMust) // 0, 7
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0"); //
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\7"); //
                            setConstraints(7);
                            break;
                    }
                }
                else if (frontIsMust && !backIsMust && leftIsMust) // 3, 7
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\3"); // 
                            setConstraints(3);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\7"); // 
                            setConstraints(7);
                            break;
                    }
                }
                else if (!frontIsMust && backIsMust && leftIsMust) // 2, 7
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\7"); // 
                            setConstraints(7);
                            break;
                    }
                }
                else if (frontIsMust && !backIsMust && !leftIsMust) // 0, 3, 7, 13
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0"); // 
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\3"); // 
                            setConstraints(3);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\7"); // 
                            setConstraints(7);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\13"); //
                            setConstraints(13);
                            break;
                    }
                }
                else if (!frontIsMust && backIsMust && !leftIsMust) // 0, 2, 7, 11
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0"); // 
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\7"); //
                            setConstraints(7);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\11"); //
                            setConstraints(11);
                            break;
                    }
                }
                else if (!frontIsMust && !backIsMust && leftIsMust) // 2, 3, 7, 12
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\3"); //
                            setConstraints(3);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\7"); //
                            setConstraints(7);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\12"); //
                            setConstraints(12);
                            break;
                    }
                }
                else // 0, 2, 3, 7, 11, 12, 13
                {
                    int newRoom = rnd.Next(7);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0"); //
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\3"); //
                            setConstraints(3);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\7"); //
                            setConstraints(7);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\11"); //
                            setConstraints(11);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\12"); //
                            setConstraints(12);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\13"); //
                            setConstraints(13);
                            break;
                    }
                }
            }
            #endregion

            #region Wenn der Weg nach vorne nicht offen sein darf
            if (!MovesFront && MovesRight && MovesBack && MovesLeft)
            {
                if (rightIsMust && backIsMust && leftIsMust) // 6
                {
                    room = content.Load<Model>("Models\\6"); // front geschlossen
                    setConstraints(6);
                }
                else if (rightIsMust && backIsMust && !leftIsMust) // 5, 6
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\5"); //
                            setConstraints(5);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\6"); //
                            setConstraints(6);
                            break;
                    }
                }
                else if (rightIsMust && !backIsMust && leftIsMust) // 1, 6
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); // 
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\6"); //
                            setConstraints(6);
                            break;
                    }
                }
                else if (!rightIsMust && backIsMust && leftIsMust) // 2, 6
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\6"); // 
                            setConstraints(6);
                            break;
                    }
                }
                else if (rightIsMust && !backIsMust && !leftIsMust) // 1, 5, 6, 14
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); // 
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\5"); // 
                            setConstraints(5);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\6"); // 
                            setConstraints(6);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\14"); //
                            setConstraints(14);
                            break;
                    }
                }
                else if (!rightIsMust && backIsMust && !leftIsMust) // 2, 5, 6, 11
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\2"); // 
                            setConstraints(2);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\5"); //
                            setConstraints(5);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\6"); //
                            setConstraints(6);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\11"); //
                            setConstraints(11);
                            break;
                    }
                }
                else if (!rightIsMust && !backIsMust && leftIsMust) // 1, 2, 6, 12
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); //
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\6"); //
                            setConstraints(6);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\12"); //
                            setConstraints(12);
                            break;
                    }
                }
                else // 1, 2, 5, 6, 11, 12, 14
                {
                    int newRoom = rnd.Next(7);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1"); //
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\2"); //
                            setConstraints(2);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\5"); //
                            setConstraints(5);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\6"); //
                            setConstraints(6);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\11"); //
                            setConstraints(11);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\12"); //
                            setConstraints(12);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\14"); //
                            setConstraints(14);
                            break;
                    }
                }
            }
            #endregion
            #endregion

            #region Wenn es alle 4 Räume sein können
            if(MovesFront && MovesRight && MovesBack && MovesLeft)
            {
                if (frontIsMust && rightIsMust && backIsMust && leftIsMust) // 10
                {
                    room = content.Load<Model>("Models\\10");
                }
                else if (frontIsMust && rightIsMust && backIsMust && !leftIsMust) // 9, 10
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);                            
                            break;
                    }
                }
                else if (frontIsMust && rightIsMust && !backIsMust && leftIsMust) // 8, 10
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && backIsMust && leftIsMust) // 7, 10
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && backIsMust && leftIsMust) // 6, 10
                {
                    int newRoom = rnd.Next(2);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            moveFront = false;
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (frontIsMust && rightIsMust && !backIsMust && !leftIsMust) // 4, 8, ,9, 10
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\4");
                            setConstraints(4);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && backIsMust && !leftIsMust) // 0, 7, 9, 10
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0");
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && backIsMust && !leftIsMust) // 5, 6, 9, 10
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\5");
                            setConstraints(5);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && !backIsMust && leftIsMust) // 3, 7, 8, 10
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\3");
                            setConstraints(3);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && !backIsMust && leftIsMust) // 1, 6, 8, 10
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1");
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (!frontIsMust && !rightIsMust && backIsMust && leftIsMust) // 2, 6, 7, 10
                {
                    int newRoom = rnd.Next(4);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\2");
                            setConstraints(2);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                    }
                }
                else if (frontIsMust && !rightIsMust && !backIsMust && !leftIsMust) // 0, 3, 4, 7, 8, 9, 10, 13
                {
                    int newRoom = rnd.Next(8);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0");
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\3");
                            setConstraints(3);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\4");
                            setConstraints(4);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                        case 7:
                            room = content.Load<Model>("Models\\13");
                            setConstraints(13);
                            break;
                    }
                }
                else if (!frontIsMust && rightIsMust && !backIsMust && !leftIsMust) // 1, 4, 5, 6, 8, 9, 10, 14
                {
                    int newRoom = rnd.Next(8);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1");
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\4");
                            setConstraints(4);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\5");
                            setConstraints(5);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                        case 7:
                            room = content.Load<Model>("Models\\14");
                            setConstraints(14);
                            break;
                    }
                }
                else if (!frontIsMust && !rightIsMust && backIsMust && !leftIsMust) // 0, 2, 5, 6, 7, 9, 10, 11
                {
                    int newRoom = rnd.Next(8);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0");
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\2");
                            setConstraints(2);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\5");
                            setConstraints(5);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                        case 7:
                            room = content.Load<Model>("Models\\11");
                            setConstraints(11);
                            break;
                    }
                }
                else if (!frontIsMust && !rightIsMust && !backIsMust && leftIsMust) // 1, 2, 3, 6, 7, 8, 10, 12
                {
                    int newRoom = rnd.Next(8);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\1");
                            setConstraints(1);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\2");
                            setConstraints(2);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\3");
                            setConstraints(3);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                        case 7:
                            room = content.Load<Model>("Models\\12");
                            setConstraints(12);
                            break;
                    }
                }
                else // alle Räume
                {
                    int newRoom = rnd.Next(15);
                    switch (newRoom)
                    {
                        case 0:
                            room = content.Load<Model>("Models\\0");
                            setConstraints(0);
                            break;
                        case 1:
                            room = content.Load<Model>("Models\\1");
                            setConstraints(1);
                            break;
                        case 2:
                            room = content.Load<Model>("Models\\2");
                            setConstraints(2);
                            break;
                        case 3:
                            room = content.Load<Model>("Models\\3");
                            setConstraints(3);
                            break;
                        case 4:
                            room = content.Load<Model>("Models\\4");
                            setConstraints(4);
                            break;
                        case 5:
                            room = content.Load<Model>("Models\\5");
                            setConstraints(5);
                            break;
                        case 6:
                            room = content.Load<Model>("Models\\6");
                            setConstraints(6);
                            break;
                        case 7:
                            room = content.Load<Model>("Models\\7");
                            setConstraints(7);
                            break;
                        case 8:
                            room = content.Load<Model>("Models\\8");
                            setConstraints(8);
                            break;
                        case 9:
                            room = content.Load<Model>("Models\\9");
                            setConstraints(9);
                            break;
                        case 10:
                            room = content.Load<Model>("Models\\10");
                            setConstraints(10);
                            break;
                        case 11:
                            room = content.Load<Model>("Models\\11");
                            setConstraints(11);
                            break;
                        case 12:
                            room = content.Load<Model>("Models\\12");
                            setConstraints(12);
                            break;
                        case 13:
                            room = content.Load<Model>("Models\\13");
                            setConstraints(13);
                            break;
                        case 14:
                            room = content.Load<Model>("Models\\14");
                            setConstraints(14);
                            break;
                    }
                }
            }
            #endregion

            boneTransforms = new Matrix[room.Bones.Count];
        }

        public void setMaxRoomWithConstraints(ContentManager content)
        {
            if (moveFront && moveRight && moveBack && moveLeft)
            {
                room = content.Load<Model>("Models//10");
                setConstraints(10);
            }
            else if (moveFront && moveRight && moveBack && !moveLeft)
            {
                room = content.Load<Model>("Models//9");
                setConstraints(9);
            }
            else if (moveFront && moveRight && !moveBack && moveLeft)
            {
                room = content.Load<Model>("Models//8");
                setConstraints(8);
            }
            else if (moveFront && !moveRight && moveBack && moveLeft)
            {
                room = content.Load<Model>("Models//7");
                setConstraints(7);
            }
            else if (!moveFront && moveRight && moveBack && moveLeft)
            {
                if (entrance)
                {
                    room = content.Load<Model>("Models//entrance2");
                }
                else
                {
                    room = content.Load<Model>("Models//6");
                }
                setConstraints(6);
            }
            else if (!moveFront && moveRight && moveBack && !moveLeft)
            {
                if (entrance)
                {
                    room = content.Load<Model>("Models//entrance1");
                }
                else
                {
                    room = content.Load<Model>("Models//5");
                }
                setConstraints(5);
            }
            else if (moveFront && moveRight && !moveBack && !moveLeft)
            {
                room = content.Load<Model>("Models//4");
                setConstraints(4);
            }
            else if (moveFront && !moveRight && !moveBack && moveLeft)
            {
                Console.WriteLine(position);
                room = content.Load<Model>("Models//3");
                setConstraints(3);
            }
            else if (!moveFront && !moveRight && moveBack && moveLeft)
            {
                if (entrance)
                {
                    room = content.Load<Model>("Models//entrance3");
                }
                else
                {
                    room = content.Load<Model>("Models//2");
                }                
                setConstraints(2);
            }
            else if (!moveFront && moveRight && !moveBack && moveLeft)
            {
                room = content.Load<Model>("Models//1");
                setConstraints(1);
            }
            else if (moveFront && !moveRight && moveBack && !moveLeft)
            {
                room = content.Load<Model>("Models//0");
                setConstraints(0);
            }
            else if (!moveFront && !moveRight && moveBack && !moveLeft)
            {
                room = content.Load<Model>("Models//11");
                setConstraints(11);
            }
            else if (!moveFront && !moveRight && !moveBack && moveLeft)
            {
                room = content.Load<Model>("Models//12");
                setConstraints(12);
            }
            else if (moveFront && !moveRight && !moveBack && !moveLeft)
            {
                room = content.Load<Model>("Models//13");
                setConstraints(13);
            }
            else if (!moveFront && moveRight && !moveBack && !moveLeft)
            {
                room = content.Load<Model>("Models//14");
                setConstraints(14);
            }            

            if (room != null)
            {
                boneTransforms = new Matrix[room.Bones.Count];
            }
            
        }

        private void setSurroundingRooms(ref Room[,] labyrinth)
        {
            if(frontIsMust && moveFront)
            {
                labyrinth[(int)position.Y-1, (int)position.X].BackIsMust = true;
            }

            if (rightIsMust && moveRight)
            {
                labyrinth[(int)position.Y, (int)position.X + 1].LeftIsMust = true;
            }

            if (backIsMust && moveBack)
            {
                labyrinth[(int)position.Y + 1, (int)position.X].FrontIsMust = true;
            }

            if (leftIsMust && moveLeft)
            {
                labyrinth[(int)position.Y, (int)position.X - 1].RightIsMust = true;
            }
        }

        public bool isRoomFullySet()
        {
            bool set = false;
            switch (roomKind)
            {
                case 0:
                    if(frontIsMust && backIsMust){
                        set = true;
                    }
                    break;
                case 1:
                    if(leftIsMust && rightIsMust){
                        set = true;
                    }
                    break;
                case 2:
                    if(leftIsMust && backIsMust ){
                        set = true;
                    }
                    break;
                case 3:
                    if(leftIsMust && frontIsMust){
                        set = true;
                    }
                    break;
                case 4:
                    if(frontIsMust && rightIsMust){
                        set = true;
                    }
                    break;
                case 5:
                    if(backIsMust && rightIsMust){
                        set = true;
                    }
                    break;
                case 6:
                    if(leftIsMust && backIsMust && rightIsMust){
                        set = true;
                    }
                    break;
                case 7:
                    if(frontIsMust && leftIsMust && backIsMust){
                        set = true;
                    }
                    break;
                case 8:
                    if (leftIsMust && frontIsMust && rightIsMust){
                        set = true;
                    }
                    break;
                case 9:
                    if(frontIsMust && rightIsMust && backIsMust){
                        set = true;
                    }
                    break;
                case 10:
                    if(frontIsMust && rightIsMust && backIsMust && leftIsMust){
                        set = true;
                    }
                    break;
                case 11:
                    if(backIsMust){
                        set = true;
                    }
                    break;
                case 12:
                    if(leftIsMust){
                        set = true;
                    }
                    break;
                case 13:
                    if(frontIsMust){
                        set = true;
                    }
                    break;
                case 14:
                    if(rightIsMust){
                        set = true;
                    }
                    break;
            }

            return set;
        }

        public List<Vector2> getFreeWays()
        {
            List<Vector2> positions = new List<Vector2>();
            if(moveFront && !frontIsMust)
            {
                positions.Add(new Vector2 ( position.X, position.Y - 1 ));
            }
                if (moveBack && !backIsMust)
                {
                    positions.Add(new Vector2 ( position.X, position.Y + 1 ));
                }
            if (moveLeft && !leftIsMust)
            {
                positions.Add(new Vector2 ( position.X - 1, position.Y ));
            }
                if (moveRight && !rightIsMust)
                {
                    positions.Add(new Vector2 ( position.X + 1, position.Y ));
                }
            return positions;
        }

        public void overrideToMaxRoom(ref Room[,] labyrinth, ContentManager content)
        {
            getConstraints(ref labyrinth);
            setMaxRoomWithConstraints(content);
        }

        public Vector3 getLocation()
        {
            return new Vector3( UtilityVariables.roomSize * (position.X - (UtilityVariables.labyrinthSize/2)), 
                                -150,
                                UtilityVariables.roomSize * (position.Y - (UtilityVariables.labyrinthSize / 2)));
        }

        public void displayConstraints()
        { 
                    Console.WriteLine("---------------begin-"+roomKind+"--("+position.Y+","+position.X+")-------------");
                    Console.WriteLine("moveFront = "+moveFront);
                    Console.WriteLine("       frontIsMust = " + frontIsMust);
                    Console.WriteLine("moveBack = " + moveBack);
                    Console.WriteLine("       backIsMust = " + backIsMust);
                    Console.WriteLine("moveLeft = " + moveLeft);
                    Console.WriteLine("       leftIsMust = " + leftIsMust);
                    Console.WriteLine("moveRight = " + moveRight);
                    Console.WriteLine("       rightIsMust = " + rightIsMust);
                    Console.WriteLine("-----------------end " + roomKind + "-----------------------");              
        }

        #region Getter und Setter
        public Model getRoom
        {
            get { return room; }
            set { room = value; }
        }
        public Matrix[] Bones
        {
            get { return boneTransforms; }
        }

        public bool MovesFront
        {
            get { return moveFront; }
        }
        public bool MovesBack
        {
            get { return moveBack; }
        }
        public bool MovesRight
        {
            get { return moveRight; }
        }
        public bool MovesLeft
        {
            get { return moveLeft; }
        }

        public bool FrontIsMust
        {
            get { return frontIsMust; }
            set { frontIsMust = value; }
        }
        public bool RightIsMust
        {
            get { return rightIsMust; }
            set { rightIsMust = value; }
        }
        public bool BackIsMust
        {
            get { return backIsMust; }
            set { backIsMust = value; }
        }
        public bool LeftIsMust
        {
            get { return leftIsMust; }
            set { leftIsMust = value; }
        }
        public Vector2 getPosition
        {
            get { return position; }
        }
        public bool isExit
        {
            get { return exit; }
        }
        public bool isEntrance
        {
            get { return entrance; }
        }
        public int RoomKind
        {
            get { return roomKind; }
        }
        #endregion
    }
}
